package com.lkd.controller;

import com.lkd.dto.SkuDto;
import com.lkd.entity.Sku;
import com.lkd.result.PageBean;
import com.lkd.result.Result;
import com.lkd.service.SkuService;
import com.lkd.vo.SkuVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

//商品管理
@RestController
public class SkuController {

    @Autowired
    private SkuService skuService;

    //分页查询
    @GetMapping("/api/vm-service/sku/search")
    public Result findByPage(SkuDto skuDto){
        PageBean<SkuVo> pageBean = skuService.findByPage(skuDto);
        return Result.success(pageBean);
    }

    //新增
    @PostMapping("/api/vm-service/sku")
    public Result save(@RequestBody Sku sku){
        Boolean result = skuService.save(sku);
        return Result.success(result);
    }


    //修改
    @PutMapping("/api/vm-service/sku")
    public Result update(@RequestBody Sku sku){
        Boolean result = skuService.update(sku);
        return Result.success(result);
    }
}
